package cn.itcast.day05.demo02;

import java.util.Scanner;

public class Demo07StringCount {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        System.out.println("请输入一个字符串:");
        String str = sc.next();
        int upperCaseCount = 0;
        int lowerCaseCount = 0;
        int numberCount = 0;
        int otherCount = 0;
        char[] charArray = str.toCharArray();
        for (int i = 0; i < charArray.length; i++) {
            if (charArray[i] <= '9' && charArray[i] >= '0') {
                numberCount++;
            } else if (charArray[i] <= 'z' && charArray[i] >= 'a') {
                lowerCaseCount++;
            } else if (charArray[i] <= 'Z' && charArray[i] >= 'A') {
                upperCaseCount++;
            } else {
                otherCount++;
            }
        }
        System.out.println("数字的个数为:" + numberCount);
        System.out.println("小写字母的个数为:" + lowerCaseCount);
        System.out.println("大写字母的个数为:" + upperCaseCount);
        System.out.println("其他字符的个数为:" + otherCount);
    }
}
